﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Money.Plugins.Import.RbsImport
{
    public partial class RbsImport : IPluginGui
    {
        void IPluginGui.Register(PluginGuiHooks pluginHooks)
        {
            ToolStripMenuItem mainMnu = new ToolStripMenuItem();
            mainMnu.Text = "RBS Transaction Importer (2008)";
            pluginHooks.MenuHook.DropDownItems.Add(mainMnu);

            ToolStripMenuItem mnu = new ToolStripMenuItem();
            mnu.Text = "Configure Description Match";
            mnu.Click += DescriptionMatchConfiguration;
            mainMnu.DropDownItems.Add(mnu);

            mnu = new ToolStripMenuItem();
            mnu.Text = "Edit Configuration";
            mnu.Click += EditConfiguration;
            mainMnu.DropDownItems.Add(mnu);
        }

        private void EditConfiguration(object sender, EventArgs e)
        {
            ConfigurationForm configGUI = new ConfigurationForm(_configuration.Item);

            if (configGUI.ShowDialog() == DialogResult.OK)
            {
                _configuration.Save();
            }
        }

        private void DescriptionMatchConfiguration(object sender, EventArgs e)
        {
            TransactionMatchForm cdm = new TransactionMatchForm(_configuration.Item.Categories, _dataAccessInterface.Categories);

            cdm.Show();

            // TODO we need to determine correct place where configuration should be saved?
            _configuration.Save();
        }
    }
}
